package cn.wolfcode.ssm.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.StringUtils;

import java.util.HashMap;

@Getter
@Setter
public class SystemDictionaryItem {
    /** */
    private Long id;
    /** 标题*/
    private String title;
    /** 序号*/
    private Long sequence;
    /** 关联字段目录对象*/
    private SystemDictionary dictionary;
    /** 关联字段上一级明细对象*/
    private SystemDictionaryItem dictionaryItem;

    public String toJson(){
        HashMap<String, Object> map = new HashMap<>();
        map.put("id",id);
        map.put("title",title);
        map.put("sequence",sequence);
        if(dictionary!=null){
            map.put("dicId",dictionary.getId());
        }
        if(dictionaryItem!=null){
            map.put("parentId",dictionaryItem.getId());
        }if(dictionaryItem!=null){
            map.put("parentTitle",dictionaryItem.getTitle());
        }
        return JSON.toJSONString(map);
    }

}